package io.mft.web.adapter.api.handler;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import io.mft.api.domain.Api;
import io.mft.dev.bootstrap.adapter.MFTRuningAdapter;
import io.mft.web.adapter.api.ApiHandler;

public class OkApiHandler implements ApiHandler{

	MFTRuningAdapter<ResponseEntity<Object>> adapter;
	public OkApiHandler(Api api,MFTRuningAdapter<ResponseEntity<Object>> adapter) {
		this.api = api;
		this.adapter=adapter;
	}

	private Api api;

	@RequestMapping
	@ResponseBody
	public ResponseEntity<Object> handle(@RequestParam(required = false) Map<String, Object> param, HttpServletRequest request) {
		return adapter.executeApi(api.getKey(), param);
	}

}